﻿using Sys.Core;
using Sys.Core.Models.Queries;
using Sys.Core.Models.VO;
using Microsoft.AspNetCore.Mvc;
using MiniFox.Infrastructure;
using MiniFox.Platform.Applications.Web;
using MiniFox.Utility;
using MiniFox.Web.Filters;
using MiniFox.Web.Infrastructure;
using Sys.Core.Models.Dto;

namespace Sys.Controllers
{
    [NoCache, ValidationFilter, Area(GlobalConstants.AREA_NAME)]
    public class OnlineController : AuthorizedController<IOnlineService>
    {
        [HttpPost]
        public Response<ResultObject<IEnumerable<OnlineVo>>> Query([FromBody] PagedQueryObject<OnlineQuery> request)
        {
            var result = this.Component.QueryOnline(request);
            return result.CreateResponse();
        }

        [HttpGet]
        public Response Logoff([FromQuery] string ticketId)
        {
            this.Component.Logoff(ticketId);
            return new();
        }

        [HttpPost]
        public Response<string> ResolveToken([FromBody] string data)
        {
            Ticket ticket = data;
            return ticket.TicketID.CreateResponse();
        }

        [HttpPost]
        public Response<ResultObject<IEnumerable<AuthTokenVo>>> AuthToken([FromBody] PagedQueryObject<AuthQuery> request)
        {
            var result = this.Component.QueryAuthToken(request);
            return result.CreateResponse();
        }

        [HttpPost]
        public Response RemoveToken([FromBody] RemoveAuthTokenDto removeAuthToken)
        {
            this.Component.RemoveAuthToken(removeAuthToken);
            return new();
        }

        [HttpPost]
        public Response<ResultObject<IEnumerable<AuthCodeVo>>> AuthCode([FromBody] PagedQueryObject<AuthQuery> request)
        {
            var result = this.Component.QueryAuthCode(request);
            return result.CreateResponse();
        }

        [HttpPost]
        public Response RemoveCode([FromBody] RemoveAuthCodeDto removeAuthCode)
        {
            this.Component.RemoveAuthCode(removeAuthCode);
            return new();
        }

    }
}
